package team.qwer.demo.module1.config;

import org.slf4j.event.Level;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import team.qwer.demo.common.util.LogFilter;

@Configuration
public class LogConfig extends WebMvcConfigurerAdapter {

    @Value(value = "${logging.level.team.qwer}")
    private Level logLevel;

    @Bean
    public FilterRegistrationBean requestValidationFilterRegistration1() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new LogFilter(logLevel));
        registration.addUrlPatterns("/*");
        return registration;
    }
}
